| Conditions | 4 |
| Total Lines | 62 |
| Code Lines | 59 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /*eslint max-len: ["error", { "code": 200 }]*/ |
||
| 134 | render() { |
||
| 135 | const { showing } = this.state; |
||
| 136 | |||
| 137 | return ( |
||
| 138 | <div className="form-wrapper"> |
||
| 139 | <h1>Registration</h1> |
||
| 140 | <p className="center">To be able to view your profile you must first register.</p> |
||
| 141 | <form action="/login" className="form-register" onSubmit={this.registerSubmit}> |
||
| 142 | <label className="form-label">Username |
||
| 143 | <input className="form-input" type="text" name="name" required placeholder="Your username" /> |
||
| 144 | </label> |
||
| 145 | |||
| 146 | <label className="form-label">Birthday |
||
| 147 | <input onClick={() => this.setState({ showing: !showing })} id="birthday" className="form-input" type="date" name="date" required placeholder="Click to choose!" /> |
||
| 148 | { showing |
||
| 149 | ? <DatePicker /> |
||
| 150 | : null |
||
| 151 | } |
||
| 152 | </label> |
||
| 153 | |||
| 154 | <label className="form-label">Country |
||
| 155 | <select onChange={this.addToCommon} className="form-input" type="text" name="country" required placeholder="Your current location"> |
||
| 156 | <optgroup label="Common countries"> |
||
| 157 | { this.state.commonOptions } |
||
| 158 | </optgroup> |
||
| 159 | <optgroup label="Other countries"> |
||
| 160 | { this.state.countries } |
||
| 161 | </optgroup> |
||
| 162 | </select> |
||
| 163 | </label> |
||
| 164 | |||
| 165 | <label className="form-label">Email |
||
| 166 | <input className="form-input" type="email" name="email" required placeholder="[email protected]" /> |
||
| 167 | </label> |
||
| 168 | |||
| 169 | <label className="form-label">Password: 1 capital letter, 1 number, 4+ characters long. |
||
| 170 | <input |
||
| 171 | className="form-input password" |
||
| 172 | type={this.state.hidden ? "password" : "text"} |
||
| 173 | name="password" |
||
| 174 | pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,}" |
||
| 175 | value={this.state.password} |
||
| 176 | placeholder="Your password" |
||
| 177 | onChange={this.onPasswordChange} |
||
| 178 | required |
||
| 179 | /> |
||
| 180 | <p><input type="checkbox" className="show-password" onClick={this.toggleShowPassword} /> {this.state.button ? "Show" : "Hide"} password</p> |
||
| 181 | </label> |
||
| 182 | |||
| 183 | <label className="form-label">Password strength |
||
| 184 | <meter className="form-meter" min="0" low="4" optimum="9" high="8" max="10" value={this.state.strength}></meter> |
||
| 185 | </label> |
||
| 186 | |||
| 187 | <label className="form-label check-label"> |
||
| 188 | <input className="check-input" type="checkbox" name="gdpr" required /> |
||
| 189 | I agree to the <a href="https://en.wikipedia.org/wiki/Terms_of_service">Terms and Conditions</a> |
||
| 190 | </label><br /> |
||
| 191 | |||
| 192 | |||
| 193 | <input className="button form-button center" type="submit" name="register" value="Register" /> |
||
| 194 | </form> |
||
| 195 | </div> |
||
| 196 | ); |
||
| 201 |